//
//  YKUserTool.m
//  youkan
//
//  Created by mac mini on 16/3/1.
//  Copyright © 2016年 Honsintech. All rights reserved.
//!> 处理用户的业务

#import "YKUserTool.h"
#import "YKHttpTool.h"
#import "YKUserParam.h"
#import "YKAccount.h"
#import "YKAccountTool.h"
#import "MJExtension.h"
#import "YKUserResult.h"
#import "YKUser.h"
@implementation YKUserTool
+(void)unreadWithSucces:(void (^)(YKUserResult *))success failure:(void (^)(NSError *))failure{
    YKUserParam *param=[[YKUserParam alloc]init];
    param.uid =[YKAccountTool account].uid;
    param.access_token =[YKAccountTool  account].access_token;
    [YKHttpTool GET:@"https://rm.api.weibo.com/2/remind/unread_count.json" parameters:param.keyValues success:^(id responseObject) {
//        字典转模型
        YKUserResult *result =[YKUserResult  objectWithKeyValues:responseObject];
        if (success) {
            success(result);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];

}
+(void)userInfoWithSucces:(void (^)(YKUser *))success failure:(void (^)(NSError *))failure{
    YKUserParam *param =[YKUserParam param];
    param.uid =[YKAccountTool account].uid;
    [YKHttpTool GET:@"https://api.weibo.com/2/users/show.json" parameters:param.keyValues success:^(id responseObject) {
    YKUser *user =[YKUser objectWithKeyValues:responseObject];
    if (success) {
        success(user);
    }
} failure:^(NSError *error) {
    if (failure) {
        failure(error);
    }
}];
}
@end
